https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/
從排序好的陣列找到最小值的轉折點並回傳此索引值。
已知是排序好的陣列在正常情況下,當for迴圈探訪的數值比上一個還小時,得知此索引值為轉折點並回傳。
int findMin(int* nums, int numsSize){
int i = 0;
if(numsSize == 0)
return;
if(numsSize == 1)
return nums[0];
for(i = 1; i<numsSize;i++)
{
if(nums[i]<nums[i-1])
return nums[i];
}
return nums[0];
}
var findMin = function(nums) {
if(nums.length==0)
return ;
if(nums.length==1)
return nums[0];
var i,j,k=0,l,r;
for(i=1;i<nums.length;i++)
{
if(nums[i]<nums[i-1])
return nums[i];
}
return nums[0];
};
https://github.com/SIAOYUCHEN/leetcode
https://ithelp.ithome.com.tw/users/20100009/ironman/2500
https://ithelp.ithome.com.tw/users/20113393/ironman/2169
https://ithelp.ithome.com.tw/users/20107480/ironman/2435
https://ithelp.ithome.com.tw/users/20107195/ironman/2382
https://ithelp.ithome.com.tw/users/20119871/ironman/2210
https://ithelp.ithome.com.tw/users/20106426/ironman/2136
Venture outside your comfort zone. The rewards are worth it.
踏出你的舒適圈去冒險吧!你會發現一切回報都是值得的